package com.sajus.web.billing.admin.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.sajus.billing.client.delegate.BusinessDelegateFactory;
import com.sajus.billing.client.dto.AccountDTO;
import com.sajus.billing.client.dto.BillDTO;
import com.sajus.billing.client.dto.BillItemDTO;
import com.sajus.billing.client.dto.ServiceDTO;
import com.sajus.billing.client.dto.UsageItemLineDTO;

/**
 * Acts as a Struts 2 controller that responds
 * to a user action by setting the value
 * of the Message model class, and returns a String 
 * result.
 * @author Bruce Phillips
 *
 */
public class BillInfoAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private List<BillDTO> bills;
	
	private Integer accountId;
	/*
	 * Creates the MessageStore model object and 
	 * returns success.  The MessageStore model
	 * object will be available to the view.
	 * (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception {
		
		String paramValue = ServletActionContext.getRequest().getParameter("accountId");
		
		if ( paramValue != null ) {
			
			accountId = new Integer( Integer.parseInt( paramValue ) );
			bills = BusinessDelegateFactory.getInstance().getAccountManager().getBills( accountId );
			
		}
		
		return SUCCESS;
	}

	public List<BillDTO> getBills() {
		return bills;
	}


	public void setBills(List<BillDTO> bills) {
		this.bills = bills;
	}

	public Integer getAccountId() {
		return accountId;
	}

	public void setAccountId(Integer accountId) {
		this.accountId = accountId;
	}
	
}
